package fairygui.editor
{
   import fairygui.GButton;
   import fairygui.GComponent;
   import fairygui.GGraph;
   import fairygui.PopupMenu;
   import fairygui.editor.dialogs.ExchangeDialog;
   import fairygui.editor.dialogs.PasteOptionDialog;
   import fairygui.editor.dialogs.insert.CreateComDialog;
   import fairygui.editor.extui.DropEvent;
   import fairygui.editor.extui.Icons;
   import fairygui.editor.gui.ActionHistory;
   import fairygui.editor.gui.EController;
   import fairygui.editor.gui.EGComponent;
   import fairygui.editor.gui.EGGroup;
   import fairygui.editor.gui.EGList;
   import fairygui.editor.gui.EGLoader;
   import fairygui.editor.gui.EGObject;
   import fairygui.editor.gui.EGTextField;
   import fairygui.editor.gui.EOverflowConst;
   import fairygui.editor.gui.EPackageItem;
   import fairygui.editor.gui.ETransition;
   import fairygui.editor.gui.ETransitionItem;
   import fairygui.editor.gui.EUIObjectFactory;
   import fairygui.editor.gui.EUISprite;
   import fairygui.editor.gui.RangeEditor;
   import fairygui.editor.gui.gear.EIAnimationGear;
   import fairygui.editor.gui.gear.EIColorGear;
   import fairygui.editor.handlers.CopyHandler;
   import fairygui.editor.utils.RuntimeErrorUtil;
   import fairygui.editor.utils.Utils;
   import fairygui.editor.utils.UtilsFile;
   import fairygui.editor.utils.UtilsStr;
   import fairygui.utils.GTimers;
   import flash.desktop.Clipboard;
   import flash.display.BitmapData;
   import flash.display.DisplayObject;
   import flash.display.Graphics;
   import flash.display.LineScaleMode;
   import flash.display.PNGEncoderOptions;
   import flash.display.Sprite;
   import flash.events.Event;
   import flash.events.KeyboardEvent;
   import flash.events.MouseEvent;
   import flash.filesystem.File;
   import flash.geom.Matrix;
   import flash.geom.Point;
   import flash.geom.Rectangle;
   import flash.ui.Keyboard;
   import flash.utils.ByteArray;
   
   public class ComDocument extends GComponent implements IDocument
   {
      
      private static var _copyInfo:Object;
      
      private static var _copiedObjects:Array;
      
      private static const autoScrollLeft:int = 30;
      
      private static const autoScrollStep:int = 10;
      
      private static const OFFSET:Array = [0,0,0,-1,1,-1,1,0,1,1,0,1,-1,1,-1,0,-1,-1];
       
      
      private var _contentHolder:Sprite;
      
      private var _container:Sprite;
      
      private var _bgGraphics:Graphics;
      
      private var _selContainer:Sprite;
      
      private var _selMC:Sprite;
      
      private var _docItem:EPackageItem;
      
      private var _docContent:EGComponent;
      
      private var _group:EGGroup;
      
      private var _designImage:EGObject;
      
      private var _selections:Vector.<EGObject>;
      
      private var _selStartPosX:Number;
      
      private var _selStartPosY:Number;
      
      private var _popupMenu:PopupMenu;
      
      private var _transitionMenu:PopupMenu;
      
      private var _active:Boolean;
      
      private var _selectingObject:Boolean;
      
      private var _groupBeforeSelect:EGGroup;
      
      private var _emptySelectionBeforeSelect:Boolean;
      
      private var _modified:Boolean;
      
      private var _savedVersion:int;
      
      private var _latestVersion:int;
      
      private var _savedScrollPercX:Number;
      
      private var _savedScrollPercY:Number;
      
      private var _savedEditingTransition:ETransition;
      
      private var _lastTextField:EGTextField;
      
      private var _pastePoint:Point;
      
      private var _menuPos:Point;
      
      private var _bgColorChanged:Boolean;
      
      private var _actionHistory:ActionHistory;
      
      private var _dragStartX:int;
      
      private var _dragStartY:int;
      
      private var _editorWindow:EditorWindow;
      
      private var _editPanel:EditPanel;
      
      private var _error:Boolean;
      
      private var _clickOnRangeEditor:Boolean;
      
      public function ComDocument()
      {
         var _loc3_:GButton = null;
         super();
         this.opaque = true;
         var _loc1_:GGraph = new GGraph();
         addChild(_loc1_);
         this._bgGraphics = _loc1_.graphics;
         this._contentHolder = new Sprite();
         this._contentHolder.mouseEnabled = false;
         var _loc2_:GGraph = new GGraph();
         addChild(_loc2_);
         _loc2_.setNativeObject(this._contentHolder);
         this._container = new Sprite();
         this._container.x = 0;
         this._container.y = 0;
         this._contentHolder.addChild(this._container);
         this._selContainer = new Sprite();
         this._selContainer.x = 0;
         this._selContainer.y = 0;
         this._contentHolder.addChild(this._selContainer);
         this._selMC = new Sprite();
         this._selMC.graphics.lineStyle(0.1);
         this._selMC.graphics.drawRect(0,0,10,10);
         this._selMC.graphics.endFill();
         this._popupMenu = new PopupMenu();
         this._popupMenu.contentPane.width = 210;
         this._popupMenu.addItem(Consts.g.text1,this.__menuCut).name = "cut";
         this._popupMenu.addItem(Consts.g.text2,this.__menuCopy).name = "copy";
         this._popupMenu.addItem(Consts.g.text3,this.__menuPaste).name = "paste";
         this._popupMenu.addItem(Consts.g.text4,this.__menuDelete).name = "delete";
         this._popupMenu.addSeperator();
         this._popupMenu.addItem(Consts.g.text5,this.__menuSelectAll).name = "selectAll";
         this._popupMenu.addItem(Consts.g.text23,this.__menuUnselectAll).name = "unselectAll";
         this._popupMenu.addSeperator();
         _loc3_ = this._popupMenu.addItem(Consts.g.text6,this.__menuMoveTop);
         _loc3_.name = "moveTop";
         if(!FairyGUIEditor.os_mac)
         {
            _loc3_.getChild("shortcut").text = "Ctrl+→";
         }
         _loc3_ = this._popupMenu.addItem(Consts.g.text7,this.__menuMoveUp);
         _loc3_.name = "moveUp";
         if(!FairyGUIEditor.os_mac)
         {
            _loc3_.getChild("shortcut").text = "Ctrl+←";
         }
         _loc3_ = this._popupMenu.addItem(Consts.g.text8,this.__menuMoveDown);
         _loc3_.name = "moveDown";
         if(!FairyGUIEditor.os_mac)
         {
            _loc3_.getChild("shortcut").text = "Ctrl+↓";
         }
         _loc3_ = this._popupMenu.addItem(Consts.g.text9,this.__menuMoveBottom);
         _loc3_.name = "moveBottom";
         if(!FairyGUIEditor.os_mac)
         {
            _loc3_.getChild("shortcut").text = "Ctrl+↑";
         }
         this._popupMenu.addSeperator();
         this._popupMenu.addItem(Consts.g.text10 + "...",this.__menuExchange).name = "exchange";
         _loc3_ = this._popupMenu.addItem(Consts.g.text238,this.__menuCreateCom);
         _loc3_.name = "createCom";
         _loc3_.getChild("shortcut").text = "F8";
         _loc3_ = this._popupMenu.addItem(Consts.g.text325,this.__menuConvertToBitmap);
         _loc3_.name = "convertToBitmap";
         this._popupMenu.addSeperator();
         this._popupMenu.addItem(Consts.g.text11,this.__menuShowInLib).name = "showInLib";
         this._transitionMenu = new PopupMenu();
         this._transitionMenu.addItem(Consts.g.text209,this.__menuTransXY).name = "xy";
         this._transitionMenu.addItem(Consts.g.text210,this.__menuTransSize).name = "size";
         this._transitionMenu.addItem(Consts.g.text211,this.__menuTransAlpha).name = "alpha";
         this._transitionMenu.addItem(Consts.g.text212,this.__menuTransRotation).name = "rotation";
         this._transitionMenu.addItem(Consts.g.text213,this.__menuTransScale).name = "scale";
         this._transitionMenu.addItem(Consts.g.text306,this.__menuTransSkew).name = "skew";
         this._transitionMenu.addItem(Consts.g.text214,this.__menuTransColor).name = "color";
         this._transitionMenu.addItem(Consts.g.text215,this.__menuTransAnimation).name = "animation";
         this._transitionMenu.addItem(Consts.g.text216,this.__menuTransPivot).name = "pivot";
         this._transitionMenu.addItem(Consts.g.text225,this.__menuTransVisible).name = "visible";
         this._transitionMenu.addItem(Consts.g.text223,this.__menuTransTrans).name = "trans";
         this._transitionMenu.addItem(Consts.g.text222,this.__menuTransSound).name = "sound";
         this._transitionMenu.addItem(Consts.g.text224,this.__menuTransShake).name = "shake";
         this._transitionMenu.addItem(Consts.g.text305,this.__menuTransColorFilter).name = "colorFilter";
         this._selections = new Vector.<EGObject>();
         this._actionHistory = new ActionHistory(this);
         this.displayObject.addEventListener(MouseEvent.MOUSE_DOWN,this.__mouseDown);
         this.displayObject.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN,this.__midMouseDown);
         this.displayObject.addEventListener(MouseEvent.RIGHT_CLICK,this.__rightClick);
         this.addEventListener(DropEvent.DROP,this.__drop);
      }
      
      public function open(param1:EPackageItem) : void
      {
         this._docItem = param1;
         this._modified = false;
         this._docContent = null;
         this._editorWindow = this._docItem.owner.project.editorWindow;
         this._editPanel = this._editorWindow.mainPanel.editPanel;
      }
      
      public function activate() : void
      {
         var newCreate:Boolean = false;
         var func:Function = null;
         if(this._active)
         {
            return;
         }
         this._docItem.touch();
         if(this._docContent && this._latestVersion != this._docItem.version && !this._modified)
         {
            this.release();
         }
         this._active = true;
         if(!this._docContent)
         {
            try
            {
               this._docContent = EUIObjectFactory.createObject(this._docItem,3) as EGComponent;
            }
            catch(err:Error)
            {
               _editorWindow.alert("Open document failed: " + RuntimeErrorUtil.toString(err));
               _error = true;
            }
            if(!this._error)
            {
               this._docContent.statusDispatcher.addListener(EGObject.SIZE_CHANGED,this.__contentSizeChanged);
               this._docContent.statusDispatcher.addListener(EGObject.XY_CHANGED,this.__contentXYChanged);
               this._container.addChild(this._docContent.displayObject);
               this._docContent.updateDisplayList(true);
               this.updateDesignImage();
               this._group = null;
               newCreate = true;
               this._savedVersion = this._docItem.version;
            }
         }
         else
         {
            this.refresh();
         }
         if(this._error)
         {
            return;
         }
         this._latestVersion = this._docItem.version;
         this._editorWindow.mainPanel.propsPanelList.refresh();
         this._editPanel.updateControllerPanel();
         this._editPanel.updateTransitionListPanel();
         this._editPanel.updateGroupPathList(this._group);
         this._editorWindow.mainPanel.updateToolbox();
         this.setUpdateChildrenPanelFlag();
         if(newCreate)
         {
            this.updateCanvasSize(true);
         }
         else
         {
            this.updateCanvasSize(false);
         }
         this.onViewScaleChanged();
         if(this._bgColorChanged)
         {
            this.drawBackground();
         }
         parent.ensureBoundsCorrect();
         if(newCreate)
         {
            func = function():void
            {
               if(_docContent == null)
               {
                  return;
               }
               var _loc1_:Number = _container.x + _docContent.width * _container.scaleX / 2 - parent.viewWidth / 2;
               var _loc2_:Number = _container.y + _docContent.height * _container.scaleY / 2 - parent.viewHeight / 2;
               if(_loc1_ > _container.x)
               {
                  _loc1_ = _container.x - 10;
               }
               if(_loc2_ > _container.y)
               {
                  _loc2_ = _container.y - 10;
               }
               parent.scrollPane.posX = _loc1_;
               parent.scrollPane.posY = _loc2_;
            };
            func();
            GTimers.inst.add(200,1,func);
         }
         else
         {
            parent.scrollPane.percX = this._savedScrollPercX;
            parent.scrollPane.percY = this._savedScrollPercY;
         }
         parent.addSizeChangeCallback(this.__docContainerSizeChanged);
         if(this._savedEditingTransition != null)
         {
            this.startEditingTransition(this._savedEditingTransition);
         }
         GTimers.inst.add(500,0,this.onDocumentUpdate);
      }
      
      public function deactivate() : void
      {
         if(!this._active)
         {
            return;
         }
         this._active = false;
         if(this._error)
         {
            return;
         }
         this.finishSelectingObject();
         this._savedEditingTransition = this._docContent.editingTransition;
         this.finishEditingTransition();
         this._savedScrollPercX = parent.scrollPane.percX;
         this._savedScrollPercY = parent.scrollPane.percY;
         this.root.nativeStage.removeEventListener(MouseEvent.MOUSE_UP,this.__stageMouseUp);
         parent.removeSizeChangeCallback(this.__docContainerSizeChanged);
         GTimers.inst.remove(this.onDocumentUpdate);
      }
      
      public function release() : void
      {
         var _loc1_:int = 0;
         var _loc2_:int = 0;
         var _loc3_:EGObject = null;
         this.deactivate();
         this._selections.length = 0;
         this._container.removeChildren();
         this._container.x = 0;
         this._container.y = 0;
         this._selContainer.x = 0;
         this._selContainer.y = 0;
         this._savedEditingTransition = null;
         if(this._designImage)
         {
            this._designImage.dispose();
            this._designImage = null;
         }
         if(this._docContent)
         {
            _loc1_ = this._docContent.numChildren;
            _loc2_ = 0;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = this._docContent.getChildAt(_loc2_);
               if(_loc3_.rangeEditor)
               {
                  _loc3_.rangeEditor.dispose();
                  _loc3_.rangeEditor = null;
               }
               _loc2_++;
            }
            if(this._modified)
            {
               this._docItem.version = this._savedVersion;
            }
            this._actionHistory.reset();
            this._docContent.dispose();
            this._docContent = null;
         }
      }
      
      public function refresh() : void
      {
         var _loc2_:EGObject = null;
         var _loc3_:RangeEditor = null;
         this._docItem.touch();
         if(!this._modified && this._latestVersion != this._docItem.version && !this._modified)
         {
            this.release();
            this.activate();
            return;
         }
         this._docContent.validateChildren();
         var _loc1_:int = 0;
         while(_loc1_ < this._selections.length)
         {
            _loc2_ = this._selections[_loc1_];
            if(!_loc2_.parent)
            {
               this._selections.splice(_loc1_,1);
               _loc3_ = _loc2_.rangeEditor;
               if(_loc3_)
               {
                  _loc3_.visible = false;
               }
            }
            else
            {
               _loc1_++;
            }
         }
      }
      
      private function onDocumentUpdate() : void
      {
         var _loc1_:Boolean = false;
         if(this._docContent && this._editorWindow.active)
         {
            _loc1_ = this._docContent.namesChanged;
            this._docContent.onDocumentUpdate();
            if(_loc1_)
            {
               this._editorWindow.mainPanel.updateToolbox();
            }
         }
      }
      
      public function get editingTarget() : EPackageItem
      {
         return this._docItem;
      }
      
      public function get editingContent() : EGComponent
      {
         return this._docContent;
      }
      
      public function get editorWindow() : EditorWindow
      {
         return this._editorWindow;
      }
      
      public function get actionHistory() : ActionHistory
      {
         return this._actionHistory;
      }
      
      public function get uid() : String
      {
         return this._docItem.owner.id + this._docItem.id;
      }
      
      public function get isModified() : Boolean
      {
         return this._modified;
      }
      
      public function setModified() : void
      {
         this._modified = true;
         this._latestVersion = this._docItem.version;
         this.updateDocTitle();
      }
      
      public function updateDocTitle() : void
      {
         this._editPanel.updateTab(this.uid,this._docItem.name,Icons.all.component,this._modified);
      }
      
      public function serialize() : XML
      {
         if(this._docContent.editingTransition)
         {
            this._editorWindow.mainPanel.propsPanelList.propsTransitionFrame.lockUpdate = true;
            this._docContent.readSnapshot();
            this._editorWindow.mainPanel.propsPanelList.propsTransitionFrame.lockUpdate = false;
         }
         var _loc1_:XML = this._docContent.serialize();
         if(this._docContent.editingTransition && this._active)
         {
            this.setTimelineUpdateFlag();
         }
         return _loc1_;
      }
      
      public function save() : void
      {
         var g:EGGroup = null;
         if(!this._modified)
         {
            return;
         }
         if(this._docContent.editingTransition)
         {
            this._editorWindow.mainPanel.propsPanelList.propsTransitionFrame.lockUpdate = true;
            this._docContent.readSnapshot();
            this._editorWindow.mainPanel.propsPanelList.propsTransitionFrame.lockUpdate = false;
         }
         if(this._group)
         {
            g = this._group;
            while(g)
            {
               if(g.needUpdate)
               {
                  g.updateImmdediately();
               }
               g = g.groupInst;
            }
         }
         try
         {
            UtilsFile.saveXML(this._docItem.file,this.serialize());
         }
         catch(err:Error)
         {
            _editorWindow.alert("Save failed!\n" + RuntimeErrorUtil.toString(err));
            return;
         }
         this._latestVersion = this._savedVersion = this._docItem.version;
         this._modified = false;
         this.updateDocTitle();
         if(this._docContent.editingTransition && this._active)
         {
            this.setTimelineUpdateFlag();
         }
      }
      
      private function updateCanvasSize(param1:Boolean = false) : void
      {
         var _loc6_:int = 0;
         var _loc7_:int = 0;
         var _loc8_:int = 0;
         var _loc9_:int = 0;
         var _loc2_:Rectangle = this._docContent.getBounds();
         _loc2_.x = _loc2_.x + this._docContent.x;
         _loc2_.y = _loc2_.y + this._docContent.y;
         _loc2_.x = _loc2_.x * this._container.scaleX;
         _loc2_.y = _loc2_.y * this._container.scaleY;
         _loc2_.width = _loc2_.width * this._container.scaleX;
         _loc2_.height = _loc2_.height * this._container.scaleY;
         var _loc3_:int = Math.max(-_loc2_.x + 50,400);
         var _loc4_:Boolean = false;
         if(param1 || _loc3_ > this._container.x)
         {
            this._container.x = _loc3_;
            this._selContainer.x = _loc3_;
            _loc4_ = true;
         }
         else
         {
            _loc3_ = this._container.x;
         }
         var _loc5_:int = Math.max(-_loc2_.y + 50,400);
         if(param1 || _loc5_ > this._container.y)
         {
            this._container.y = _loc5_;
            this._selContainer.y = _loc5_;
            _loc4_ = true;
         }
         else
         {
            _loc5_ = this._container.y;
         }
         if(param1)
         {
            _loc6_ = _loc3_ + Math.max(_loc2_.right + 50,this._docContent.width * this._container.scaleX + 400);
            _loc7_ = _loc5_ + Math.max(_loc2_.bottom + 50,this._docContent.height * this._container.scaleY + 400);
         }
         else
         {
            _loc6_ = Math.max(_loc3_ + Math.max(_loc2_.right + 50,this._docContent.width * this._container.scaleX + 400),this.width - this._contentHolder.x);
            _loc7_ = Math.max(_loc5_ + Math.max(_loc2_.bottom + 50,this._docContent.height * this._container.scaleY + 400),this.height - this._contentHolder.y);
         }
         if(_loc6_ < parent.viewWidth)
         {
            _loc8_ = (parent.viewWidth - _loc6_) / 2;
         }
         else
         {
            _loc8_ = 0;
         }
         if(_loc7_ < parent.viewHeight)
         {
            _loc9_ = (parent.viewHeight - _loc7_) / 2;
         }
         else
         {
            _loc9_ = 0;
         }
         this._contentHolder.x = _loc8_;
         this._contentHolder.y = _loc9_;
         _loc6_ = _loc6_ + _loc8_;
         _loc7_ = _loc7_ + _loc9_;
         if(_loc6_ != this.width || _loc7_ != this.height)
         {
            this.setSize(_loc6_,_loc7_);
            this.drawBackground();
         }
         else if(_loc4_)
         {
            this.drawBackground();
         }
      }
      
      public function drawBackground() : void
      {
         var _loc7_:uint = 0;
         this._bgColorChanged = false;
         this._bgGraphics.clear();
         var _loc1_:int = Math.max(this.width,parent.width);
         var _loc2_:int = Math.max(this.height,parent.height);
         var _loc3_:int = this._contentHolder.x + this._container.x;
         var _loc4_:int = this._contentHolder.y + this._container.y;
         var _loc5_:int = _loc3_ + this._docContent.width * this._container.scaleX - 1;
         var _loc6_:int = _loc4_ + this._docContent.height * this._container.scaleY - 1;
         if(this._docContent.bgColorEnabled)
         {
            _loc7_ = this._docContent.bgColor;
         }
         else
         {
            _loc7_ = this._docItem.owner.project.editorWindow.mainPanel.bgColor2;
         }
         var _loc8_:uint = this._docItem.owner.project.editorWindow.mainPanel.bgColor == 0?uint(16777215):uint(0);
         if(_loc7_ == this._docItem.owner.project.editorWindow.mainPanel.bgColor)
         {
            this._bgGraphics.lineStyle(0,0,0,true,LineScaleMode.NONE);
            this._bgGraphics.beginFill(_loc7_,1);
            this._bgGraphics.drawRect(_loc3_,_loc4_,this._docContent.width * this._container.scaleX,this._docContent.height * this._container.scaleY);
            this._bgGraphics.endFill();
            this._bgGraphics.lineStyle(1,_loc8_,1,true);
            Utils.drawDashedLine(this._bgGraphics,_loc3_,0,_loc3_,_loc2_,4);
            Utils.drawDashedLine(this._bgGraphics,_loc5_,0,_loc5_,_loc2_,4);
            Utils.drawDashedLine(this._bgGraphics,0,_loc4_,_loc1_,_loc4_,4);
            Utils.drawDashedLine(this._bgGraphics,0,_loc6_,_loc1_,_loc6_,4);
         }
         else
         {
            this._bgGraphics.lineStyle(1,_loc8_,1,true);
            Utils.drawDashedLine(this._bgGraphics,_loc3_,0,_loc3_,_loc2_,4);
            Utils.drawDashedLine(this._bgGraphics,_loc5_,0,_loc5_,_loc2_,4);
            Utils.drawDashedLine(this._bgGraphics,0,_loc4_,_loc1_,_loc4_,4);
            Utils.drawDashedLine(this._bgGraphics,0,_loc6_,_loc1_,_loc6_,4);
            this._bgGraphics.lineStyle(0,0,0,true,LineScaleMode.NONE);
            this._bgGraphics.beginFill(_loc7_,1);
            this._bgGraphics.drawRect(_loc3_,_loc4_,this._docContent.width * this._container.scaleX,this._docContent.height * this._container.scaleY);
            this._bgGraphics.endFill();
         }
      }
      
      public function updateDesignImage() : void
      {
         if(this._designImage != null)
         {
            if(this._docContent.designImage == this._designImage.resourceURL)
            {
               this._designImage.x = this._docContent.designImageOffsetX;
               this._designImage.y = this._docContent.designImageOffsetY;
               this._designImage.alpha = this._docContent.designImageAlpha / 100;
               if(this._docContent.designImageLayer == 0)
               {
                  this._container.addChildAt(this._designImage.displayObject,0);
               }
               else
               {
                  this._container.addChild(this._designImage.displayObject);
               }
               return;
            }
            this._container.removeChild(this._designImage.displayObject);
            this._designImage.dispose();
            this._designImage = null;
         }
         if(!this._docContent.designImage)
         {
            return;
         }
         var _loc1_:EPackageItem = this._docItem.owner.project.getItemByURL(this._docContent.designImage);
         if(_loc1_ != null)
         {
            this._designImage = EUIObjectFactory.createObject(_loc1_);
            this._designImage.name = "designImage";
            this._designImage.touchable = false;
            if(this._docContent.designImageLayer == 0)
            {
               this._container.addChildAt(this._designImage.displayObject,0);
            }
            else
            {
               this._container.addChild(this._designImage.displayObject);
            }
            this._designImage.x = this._docContent.designImageOffsetX;
            this._designImage.y = this._docContent.designImageOffsetY;
            this._designImage.alpha = this._docContent.designImageAlpha / 100;
         }
      }
      
      public function hasClipboardData() : Boolean
      {
         return Clipboard.generalClipboard.hasFormat("fairygui.GObject") && _copiedObjects != null || Clipboard.generalClipboard.hasFormat("air:text") || Clipboard.generalClipboard.hasFormat("air:bitmap");
      }
      
      public function canUndo() : Boolean
      {
         return this._actionHistory.canUndo();
      }
      
      public function canRedo() : Boolean
      {
         return this._actionHistory.canRedo();
      }
      
      public function addSelection(param1:EGObject, param2:Boolean = false, param3:Boolean = false) : void
      {
         var _loc5_:EGObject = null;
         var _loc6_:Rectangle = null;
         var _loc7_:TimelinePanel = null;
         if(param1 == null || param1.groupInst != this._group)
         {
            return;
         }
         if(!param2)
         {
            this._actionHistory.action_selectionAdd(param1);
         }
         var _loc4_:int = this._selections.indexOf(param1);
         if(_loc4_ != -1)
         {
            _loc5_ = this._selections[this._selections.length - 1];
            this._selections[this._selections.length - 1] = param1;
            this._selections[_loc4_] = _loc5_;
            return;
         }
         this._selections.push(param1);
         this.installRangeEditor(param1,true);
         if(param3)
         {
            _loc6_ = new Rectangle(this._container.x + param1.x * this._container.scaleX,this._container.y + param1.y * this._container.scaleY,param1.width * this._container.scaleX,param1.height * this._container.scaleY);
            parent.scrollPane.scrollToView(_loc6_);
         }
         this.setUpdateFlag();
         this.setChildrenPanelSelection();
         if(this.editingTransition != null)
         {
            _loc7_ = this._editorWindow.mainPanel.editPanel.timelinePanel;
            _loc7_.onSelectObject(param1);
         }
      }
      
      public function hasSelection() : Boolean
      {
         return this._selections.length > 0;
      }
      
      public function inSelection(param1:EGObject) : Boolean
      {
         return this._selections.indexOf(param1) != -1;
      }
      
      public function openAndSetSelection(param1:EGObject) : void
      {
         if(param1.groupInst != this._group)
         {
            this.openGroup(param1.groupInst);
         }
         this.clearSelection();
         this.addSelection(param1,false,true);
      }
      
      public function addSelectionByName(param1:String) : void
      {
         var _loc4_:EGObject = null;
         var _loc2_:int = this._docContent.numChildren;
         var _loc3_:int = 0;
         while(_loc3_ < _loc2_)
         {
            _loc4_ = this._docContent.getChildAt(_loc3_);
            if(_loc4_.name == param1)
            {
               if(_loc4_.groupInst != this._group)
               {
                  this.openGroup(_loc4_.groupInst);
               }
               this.addSelection(_loc4_,false,true);
            }
            _loc3_++;
         }
      }
      
      private function getSelection() : EGObject
      {
         if(this._selections.length == 0)
         {
            return null;
         }
         return this._selections[this._selections.length - 1];
      }
      
      public function getSelections() : Vector.<EGObject>
      {
         return this._selections;
      }
      
      private function getSelectionRect() : Rectangle
      {
         var _loc5_:EGObject = null;
         var _loc1_:Rectangle = new Rectangle();
         var _loc2_:int = this._selections.length;
         var _loc3_:Array = [];
         var _loc4_:int = 0;
         while(_loc4_ < _loc2_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc1_ = _loc1_.union(new Rectangle(_loc5_.x,_loc5_.y,_loc5_.width,_loc5_.height));
            _loc4_++;
         }
         return _loc1_;
      }
      
      public function removeSelection(param1:EGObject, param2:Boolean = false) : void
      {
         var _loc3_:int = this._selections.indexOf(param1);
         if(_loc3_ == -1)
         {
            return;
         }
         if(!param2)
         {
            this._actionHistory.action_selectionRemove(param1);
         }
         this._selections.splice(_loc3_,1);
         var _loc4_:RangeEditor = param1.rangeEditor;
         if(_loc4_)
         {
            _loc4_.visible = false;
         }
         this.setUpdateFlag();
         this.setChildrenPanelSelection();
      }
      
      public function clearSelection(param1:Boolean = false) : void
      {
         var _loc4_:EGObject = null;
         var _loc5_:RangeEditor = null;
         var _loc6_:TimelinePanel = null;
         var _loc2_:int = this._selections.length;
         if(_loc2_ == 0)
         {
            return;
         }
         var _loc3_:int = _loc2_ - 1;
         while(_loc3_ >= 0)
         {
            _loc4_ = this._selections[_loc3_];
            _loc5_ = _loc4_.rangeEditor;
            if(_loc5_)
            {
               _loc5_.visible = false;
            }
            if(!param1)
            {
               this._actionHistory.action_selectionRemove(_loc4_);
            }
            _loc3_--;
         }
         this._selections.length = 0;
         this.setUpdateFlag();
         this.setChildrenPanelSelection();
         if(this.editingTransition != null)
         {
            _loc6_ = this._editorWindow.mainPanel.editPanel.timelinePanel;
            _loc6_.onSelectObject(null);
         }
      }
      
      private function getSortedSelectionList() : Array
      {
         var _loc4_:EGObject = null;
         var _loc5_:int = 0;
         var _loc6_:EGObject = null;
         var _loc7_:int = 0;
         var _loc1_:int = this._selections.length;
         var _loc2_:Array = [];
         var _loc3_:int = 0;
         while(_loc3_ < _loc1_)
         {
            _loc4_ = this._selections[_loc3_];
            if(_loc4_ is EGGroup)
            {
               _loc5_ = this._docContent.numChildren;
               _loc7_ = 0;
               while(_loc7_ < _loc5_)
               {
                  _loc6_ = this._docContent.getChildAt(_loc7_);
                  if(_loc6_.inGroup(EGGroup(_loc4_)))
                  {
                     _loc2_.push({
                        "index":_loc7_,
                        "obj":_loc6_
                     });
                  }
                  _loc7_++;
               }
            }
            _loc2_.push({
               "index":this._docContent.getChildIndex(_loc4_),
               "obj":_loc4_
            });
            _loc3_++;
         }
         _loc2_.sortOn("index",Array.NUMERIC);
         return _loc2_;
      }
      
      private function copySelection() : void
      {
         var _loc4_:Boolean = false;
         var _loc6_:Object = null;
         var _loc7_:EGObject = null;
         var _loc8_:XML = null;
         var _loc9_:int = 0;
         var _loc1_:Rectangle = this.getSelectionRect();
         var _loc2_:Array = this.getSortedSelectionList();
         var _loc3_:int = _loc2_.length;
         if(_loc3_ == 0)
         {
            return;
         }
         _copyInfo = {
            "src":this._docItem,
            "rect":_loc1_
         };
         _copiedObjects = new Array(_loc3_);
         var _loc5_:int = 0;
         while(_loc5_ < _loc3_)
         {
            _loc6_ = _loc2_[_loc5_];
            _loc7_ = _loc6_.obj;
            _loc8_ = _loc7_.toXML();
            _copiedObjects[_loc5_] = _loc8_;
            _loc8_.@xy = _loc7_.x - _loc1_.x + "," + (_loc7_.y - _loc1_.y);
            if(_loc7_.packageItem != null)
            {
               _loc8_.@pkg = _loc7_.pkg.id;
            }
            if(_loc7_.groupInst != null)
            {
               _loc4_ = false;
               _loc9_ = _loc5_ + 1;
               while(_loc9_ < _loc3_)
               {
                  if(_loc2_[_loc9_].obj == _loc7_.groupInst)
                  {
                     _loc4_ = true;
                     break;
                  }
                  _loc9_++;
               }
               if(!_loc4_)
               {
                  delete _loc8_.@group;
               }
            }
            _loc5_++;
         }
         Clipboard.generalClipboard.setData("fairygui.GObject","fairygui.GObject");
      }
      
      public function deleteSelection() : void
      {
         var _loc3_:EGObject = null;
         var _loc4_:RangeEditor = null;
         if(this._selectingObject)
         {
            return;
         }
         var _loc1_:int = this._selections.length;
         var _loc2_:int = 0;
         while(_loc2_ < _loc1_)
         {
            _loc3_ = this._selections[_loc2_];
            _loc4_ = _loc3_.rangeEditor;
            if(_loc4_)
            {
               _loc4_.visible = false;
            }
            this._actionHistory.action_selectionRemove(_loc3_);
            if(_loc3_ is EGGroup)
            {
               this.deleteGroupContent(EGGroup(_loc3_));
            }
            this.content_removeChild(_loc3_);
            _loc2_++;
         }
         this._selections.length = 0;
         this.setUpdateFlag();
         this.setUpdateChildrenPanelFlag();
      }
      
      public function deleteGroupContent(param1:EGGroup) : void
      {
         var _loc3_:int = 0;
         var _loc4_:EGObject = null;
         var _loc2_:int = this._docContent.numChildren;
         while(_loc3_ < _loc2_)
         {
            _loc4_ = this._docContent.getChildAt(_loc3_);
            if(_loc4_.inGroup(param1))
            {
               this.content_removeChild(_loc4_);
               _loc2_--;
            }
            else
            {
               _loc3_++;
            }
         }
      }
      
      private function makeSelectionsFixed(param1:Boolean) : void
      {
         var _loc4_:EGObject = null;
         var _loc2_:int = this._selections.length;
         var _loc3_:int = 0;
         while(_loc3_ < _loc2_)
         {
            _loc4_ = this._selections[_loc3_];
            _loc4_.fixedByDoc = param1;
            _loc3_++;
         }
      }
      
      public function moveSelection(param1:Number, param2:Number) : void
      {
         var _loc5_:EGObject = null;
         var _loc6_:int = 0;
         var _loc7_:Number = NaN;
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections.length;
         var _loc4_:int = 0;
         while(_loc4_ < _loc3_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc6_ = this.getOutlineLocks(_loc5_);
            _loc7_ = _loc5_.x + param1;
            if(!(_loc6_ & 1))
            {
               _loc5_.setProperty("x",_loc7_);
            }
            _loc7_ = _loc5_.y + param2;
            if(!(_loc6_ & 2))
            {
               _loc5_.setProperty("y",_loc7_);
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function doSelectAll() : void
      {
         var _loc3_:EGObject = null;
         var _loc1_:int = this._docContent.numChildren;
         var _loc2_:int = 0;
         while(_loc2_ < _loc1_)
         {
            _loc3_ = this._docContent.getChildAt(_loc2_);
            if(_loc3_.displayObject.parent && _loc3_.groupInst == this._group && !_loc3_.locked && !_loc3_.hideByEditor)
            {
               this.addSelection(_loc3_);
            }
            _loc2_++;
         }
      }
      
      public function doUnselectAll() : void
      {
         this.clearSelection();
      }
      
      public function doCopy() : void
      {
         this.copySelection();
      }
      
      public function doCut() : void
      {
         this.copySelection();
         this.deleteSelection();
      }
      
      public function doDelete() : void
      {
         this.deleteSelection();
         this.root.nativeStage.focus = null;
      }
      
      public function getMousePos() : Point
      {
         var _loc1_:Point = this._container.globalToLocal(new Point(displayObject.stage.mouseX,displayObject.stage.mouseY));
         _loc1_.x = _loc1_.x - this._docContent.x;
         _loc1_.y = _loc1_.y - this._docContent.y;
         _loc1_.x = int(_loc1_.x);
         _loc1_.y = int(_loc1_.y);
         return _loc1_;
      }
      
      public function getCenterPos() : Point
      {
         var _loc1_:Point = parent.localToGlobal(parent.width / 2,parent.height / 2);
         _loc1_ = this._container.globalToLocal(_loc1_);
         return _loc1_;
      }
      
      public function doPaste(param1:Point = null, param2:Boolean = false) : void
      {
         var _loc3_:BitmapData = null;
         var _loc4_:ByteArray = null;
         var _loc5_:File = null;
         var _loc6_:File = null;
         var _loc7_:String = null;
         var _loc8_:Array = null;
         if(this._selectingObject)
         {
            return;
         }
         if(Clipboard.generalClipboard.hasFormat("fairygui.GObject"))
         {
            if(_copiedObjects == null)
            {
               return;
            }
            this._pastePoint = param1;
            if(this._pastePoint == null)
            {
               if(param2)
               {
                  this._pastePoint = this.getCenterPos();
                  this._pastePoint.x = this._pastePoint.x - _copyInfo.rect.width / 2;
                  this._pastePoint.y = this._pastePoint.y - _copyInfo.rect.height / 2;
               }
               else
               {
                  this._pastePoint = _copyInfo.rect.topLeft;
               }
            }
            this._pastePoint.x = int(this._pastePoint.x);
            this._pastePoint.y = int(this._pastePoint.y);
            this.doPasteStep2();
         }
         else if(Clipboard.generalClipboard.hasFormat("air:bitmap"))
         {
            _loc3_ = Clipboard.generalClipboard.getData("air:bitmap") as BitmapData;
            _loc4_ = _loc3_.encode(_loc3_.rect,new PNGEncoderOptions());
            _loc5_ = new File(this._editorWindow.project.objsPath + "/temp");
            if(!_loc5_.exists)
            {
               _loc5_.createDirectory();
            }
            _loc6_ = _loc5_.resolvePath("Bitmap.png");
            UtilsFile.saveBytes(_loc6_,_loc4_);
            this._editorWindow.mainPanel.importResources([_loc6_],this._docContent.pkg,["/"],{"dropTarget":"document"});
         }
         else if(Clipboard.generalClipboard.hasFormat("air:text"))
         {
            _loc7_ = Clipboard.generalClipboard.getData("air:text") as String;
            if(_loc7_)
            {
               _loc8_ = this.dropObjects(["text"]);
               if(_loc8_ && _loc8_.length)
               {
                  EGTextField(_loc8_[0]).text = _loc7_;
               }
            }
         }
      }
      
      private function doPasteStep2() : void
      {
         var xml:XML = null;
         var displayList:XML = null;
         var cnt:int = 0;
         var i:int = 0;
         var copyHandler:CopyHandler = null;
         var data:Array = null;
         if(!_copyInfo.src.owner.project.opened)
         {
            return;
         }
         if(_copyInfo.src.owner != this._docItem.owner)
         {
            xml = <dummy/>;
            displayList = <displayList/>;
            cnt = _copiedObjects.length;
            i = 0;
            while(i < cnt)
            {
               displayList.appendChild(_copiedObjects[i].copy());
               i++;
            }
            xml.appendChild(displayList);
            copyHandler = new CopyHandler();
            copyHandler.copyXML(_copyInfo.src.owner,xml,this._docItem.owner,"/",true);
            if(copyHandler.existsItemCount > 0)
            {
               PasteOptionDialog(this._editorWindow.getDialog(PasteOptionDialog)).open(function(param1:int):void
               {
                  copyHandler.paste(_docItem.owner,param1);
                  doPasteStep3(displayList.elements());
               });
            }
            else
            {
               copyHandler.paste(this._docItem.owner,CopyHandler.RENAME);
               this.doPasteStep3(displayList.elements());
            }
         }
         else
         {
            data = _copiedObjects.concat();
            i = 0;
            while(i < cnt)
            {
               data[i] = data[i].copy();
               i++;
            }
            this.doPasteStep3(data);
         }
      }
      
      private function doPasteStep3(param1:Object) : void
      {
         var _loc2_:XML = null;
         var _loc3_:String = null;
         var _loc4_:String = null;
         var _loc7_:Array = null;
         var _loc8_:int = 0;
         var _loc9_:int = 0;
         var _loc10_:String = null;
         var _loc11_:XMLList = null;
         var _loc12_:XML = null;
         var _loc13_:EGObject = null;
         var _loc5_:Object = {};
         var _loc6_:* = _copyInfo.src == this._docItem;
         for each(_loc2_ in param1)
         {
            _loc3_ = _loc2_.@id;
            if(!_loc6_ || this._docContent.isIdInUse(_loc3_))
            {
               _loc4_ = this._docContent.getNextId();
               _loc5_[_loc3_] = _loc4_;
               _loc2_.@id = _loc4_;
               _loc10_ = _loc2_.@name;
               if(UtilsStr.startsWith(_loc3_,_loc10_))
               {
                  _loc2_.@name = UtilsStr.getNameFromId(_loc4_);
               }
            }
         }
         for each(_loc2_ in param1)
         {
            _loc3_ = _loc2_.@group;
            if(_loc3_)
            {
               _loc4_ = _loc5_[_loc3_];
               if(_loc4_)
               {
                  _loc2_.@group = _loc4_;
               }
            }
            else if(this._group)
            {
               _loc2_.@group = this._group.id;
            }
            _loc11_ = _loc2_.relation;
            for each(_loc12_ in _loc11_)
            {
               _loc4_ = _loc5_[_loc12_.@target];
               if(_loc4_)
               {
                  _loc12_.@target = _loc4_;
               }
            }
         }
         this.clearSelection();
         _loc7_ = [];
         _loc9_ = 0;
         if(this._group)
         {
            _loc8_ = this._docContent.getGroupTopIndex(this._group) + 1;
         }
         else
         {
            _loc8_ = this._docContent.numChildren;
         }
         for each(_loc2_ in param1)
         {
            _loc13_ = this._docContent.xmlCreateChild(_loc2_);
            _loc13_.underConstruct = true;
            _loc13_.fromXML_beforeAdd(_loc2_);
            _loc13_.x = _loc13_.x + this._pastePoint.x;
            _loc13_.y = _loc13_.y + this._pastePoint.y;
            _loc13_.locked = false;
            this._docContent.addChildAt(_loc13_,_loc8_++);
            this._actionHistory.action_childAdd(_loc13_);
            _loc7_.push(_loc13_);
         }
         for each(_loc2_ in param1)
         {
            _loc13_ = _loc7_[_loc9_++];
            _loc13_.relations.fromXML(_loc2_);
            _loc13_.fromXML_afterAdd(_loc2_);
            _loc13_.underConstruct = false;
            if(_loc13_.groupInst)
            {
               _loc13_.groupInst.update();
            }
            this.addSelection(_loc13_);
         }
         this.setUpdateChildrenPanelFlag();
      }
      
      private function installRangeEditor(param1:EGObject, param2:Boolean) : void
      {
         var _loc3_:RangeEditor = param1.rangeEditor;
         if(!_loc3_)
         {
            _loc3_ = new RangeEditor(this,param1);
            this._selContainer.addChild(_loc3_);
            _loc3_.visible = false;
         }
         if(param2)
         {
            _loc3_.visible = true;
         }
      }
      
      private function getObjectOnMouse(param1:MouseEvent) : EGObject
      {
         var _loc3_:EGObject = null;
         var _loc4_:EGGroup = null;
         this._clickOnRangeEditor = false;
         var _loc2_:DisplayObject = DisplayObject(param1.target);
         while(_loc2_ && _loc2_ != this._container)
         {
            if(_loc2_ is RangeEditor)
            {
               this._clickOnRangeEditor = true;
               return RangeEditor(_loc2_).target;
            }
            if(_loc2_ is EUISprite)
            {
               _loc3_ = EUISprite(_loc2_).owner;
               if(_loc3_.editMode == 2 && !_loc3_.locked)
               {
                  _loc4_ = _loc3_.groupInst;
                  if(_loc4_ == this._group)
                  {
                     return _loc3_;
                  }
                  if(_loc4_ != null && _loc4_.groupInst == this._group)
                  {
                     return _loc4_;
                  }
               }
            }
            _loc2_ = _loc2_.parent;
         }
         return null;
      }
      
      private function __mouseDown(param1:MouseEvent) : void
      {
         if(!this._docContent || this._editorWindow.cursorManager.isColorPicking)
         {
            return;
         }
         displayObject.stage.addEventListener(MouseEvent.MOUSE_UP,this.__stageMouseUp);
         displayObject.addEventListener(MouseEvent.MOUSE_UP,this.__mouseUp);
         if(this._editPanel.editType == 1)
         {
            this._dragStartX = param1.stageX;
            this._dragStartY = param1.stageY;
            displayObject.stage.addEventListener(MouseEvent.MOUSE_MOVE,this.__mouseMove);
            return;
         }
         var _loc2_:EGObject = this.getObjectOnMouse(param1);
         if(_loc2_ && !_loc2_.locked)
         {
            if(!this._clickOnRangeEditor)
            {
               this.installRangeEditor(_loc2_,false);
               _loc2_.rangeEditor.dragMe(param1);
            }
         }
         else
         {
            this._selStartPosX = this._selContainer.mouseX;
            this._selStartPosY = this._selContainer.mouseY;
            displayObject.stage.addEventListener(MouseEvent.MOUSE_MOVE,this.__mouseMove);
         }
      }
      
      private function __midMouseDown(param1:MouseEvent) : void
      {
         if(!this._docContent || this._editorWindow.cursorManager.isColorPicking)
         {
            return;
         }
         displayObject.stage.addEventListener(MouseEvent.MIDDLE_MOUSE_UP,this.__midMouseUp);
         displayObject.stage.addEventListener(MouseEvent.MOUSE_MOVE,this.__mouseMove);
         this._editPanel.editType = 1;
         this.__mouseDown(param1);
      }
      
      private function __midMouseUp(param1:MouseEvent) : void
      {
         param1.currentTarget.removeEventListener(MouseEvent.MIDDLE_MOUSE_UP,this.__midMouseUp);
         param1.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE,this.__mouseMove);
         this._editPanel.editType = 0;
      }
      
      private function __mouseMove(param1:MouseEvent) : void
      {
         var _loc4_:Number = NaN;
         var _loc5_:Number = NaN;
         if(this._editPanel.editType == 1)
         {
            _loc4_ = param1.stageX - this._dragStartX;
            _loc5_ = param1.stageY - this._dragStartY;
            this._dragStartX = param1.stageX;
            this._dragStartY = param1.stageY;
            parent.scrollPane.posX = parent.scrollPane.posX - _loc4_;
            parent.scrollPane.posY = parent.scrollPane.posY - _loc5_;
            return;
         }
         var _loc2_:int = Math.abs(this._selContainer.mouseX - this._selStartPosX);
         var _loc3_:int = Math.abs(this._selContainer.mouseY - this._selStartPosY);
         if(!this._selMC.parent)
         {
            if(_loc2_ < 2 && _loc3_ < 2)
            {
               return;
            }
            this._selContainer.addChild(this._selMC);
         }
         this._selMC.x = Math.min(this._selContainer.mouseX,this._selStartPosX);
         this._selMC.y = Math.min(this._selContainer.mouseY,this._selStartPosY);
         this._selMC.width = _loc2_;
         this._selMC.height = _loc3_;
      }
      
      private function __mouseUp(param1:MouseEvent) : void
      {
         var _loc2_:EGObject = null;
         var _loc3_:int = 0;
         displayObject.removeEventListener(MouseEvent.MOUSE_UP,this.__mouseUp);
         if(!this._docContent)
         {
            return;
         }
         if(this._editPanel.editType == 1)
         {
            return;
         }
         if(!this._selMC.parent)
         {
            _loc2_ = this.getObjectOnMouse(param1);
            if(RangeEditor.dragging != null && _loc2_ != RangeEditor.dragging || this._editorWindow.dragManager.dragging)
            {
               return;
            }
            if(!_loc2_)
            {
               if(param1.shiftKey)
               {
                  return;
               }
               this.clearSelection();
               if(param1.clickCount == 2)
               {
                  this.closeGroup();
               }
            }
            else if(!param1.shiftKey)
            {
               _loc3_ = this._selections.indexOf(_loc2_);
               if(_loc3_ == -1)
               {
                  if(!RangeEditor.dragging)
                  {
                     this.clearSelection();
                  }
                  this.addSelection(_loc2_);
               }
               else if(_loc3_ != this._selections.length - 1)
               {
                  this._selections.splice(_loc3_,1);
                  this._selections.push(_loc2_);
                  this.setUpdateFlag();
               }
               if(param1.clickCount == 2)
               {
                  this.openChild(_loc2_);
               }
            }
            else if(this._selections.indexOf(_loc2_) != -1)
            {
               if(_loc2_.rangeEditor == null || !RangeEditor.dragging)
               {
                  this.removeSelection(_loc2_);
               }
            }
            else
            {
               this.addSelection(_loc2_);
            }
         }
      }
      
      public function openChild(param1:EGObject) : void
      {
         if(param1 is EGGroup)
         {
            this.openGroup(EGGroup(param1));
         }
         else if(!this.isSelectingObject && !this._docContent.editingTransition)
         {
            if(param1.packageItem)
            {
               this._editorWindow.mainPanel.openItem(param1.packageItem);
            }
            else if(param1 is EGList)
            {
               if(EGList(param1).defaultItem)
               {
                  this._editorWindow.mainPanel.openItem(param1.pkg.project.getItemByURL(EGList(param1).defaultItem));
               }
            }
         }
      }
      
      private function __stageMouseUp(param1:MouseEvent) : void
      {
         var _loc2_:Point = null;
         var _loc3_:Rectangle = null;
         var _loc4_:int = 0;
         var _loc5_:int = 0;
         var _loc6_:EGObject = null;
         displayObject.stage.removeEventListener(MouseEvent.MOUSE_UP,this.__stageMouseUp);
         displayObject.stage.removeEventListener(MouseEvent.MOUSE_MOVE,this.__mouseMove);
         if(this._editPanel.editType == 1)
         {
            return;
         }
         if(this._selMC.parent)
         {
            this._selMC.parent.removeChild(this._selMC);
            this.clearSelection();
            _loc2_ = new Point(this._selMC.x,this._selMC.y);
            _loc2_ = this._container.localToGlobal(_loc2_);
            _loc2_ = this._docContent.displayObject.globalToLocal(_loc2_);
            _loc3_ = new Rectangle(_loc2_.x,_loc2_.y,this._selMC.width,this._selMC.height);
            _loc4_ = this._docContent.numChildren;
            _loc5_ = 0;
            while(_loc5_ < _loc4_)
            {
               _loc6_ = this._docContent.getChildAt(_loc5_);
               if(_loc6_.displayObject.parent && _loc6_.groupInst == this._group && !_loc6_.locked && (_loc3_.containsPoint(new Point(_loc6_.x,_loc6_.y)) || _loc3_.intersects(new Rectangle(_loc6_.x,_loc6_.y,Math.max(_loc6_.width,1),Math.max(_loc6_.height,1)))))
               {
                  this.addSelection(_loc6_);
               }
               _loc5_++;
            }
         }
         this.updateCanvasSize();
      }
      
      private function __rightClick(param1:MouseEvent) : void
      {
         if(!this._docContent || this._selectingObject || this._editorWindow.cursorManager.isColorPicking)
         {
            return;
         }
         this.__mouseUp(param1);
         this.showContextMenu();
      }
      
      public function showContextMenu() : void
      {
         var _loc2_:EGObject = null;
         var _loc3_:* = false;
         var _loc4_:Boolean = false;
         var _loc1_:* = this._selections.length == 0;
         this._menuPos = this.getMousePos();
         if(this._docContent.editingTransition == null)
         {
            this._popupMenu.setItemGrayed("copy",_loc1_);
            this._popupMenu.setItemGrayed("cut",_loc1_);
            this._popupMenu.setItemGrayed("paste",!this.hasClipboardData());
            this._popupMenu.setItemGrayed("delete",_loc1_);
            this._popupMenu.setItemGrayed("unselectAll",_loc1_);
            this._popupMenu.setItemGrayed("moveTop",_loc1_);
            this._popupMenu.setItemGrayed("moveBottom",_loc1_);
            this._popupMenu.setItemGrayed("moveUp",_loc1_);
            this._popupMenu.setItemGrayed("moveDown",_loc1_);
            this._popupMenu.setItemGrayed("exchange",_loc1_);
            this._popupMenu.setItemGrayed("showInLib",_loc1_);
            this._popupMenu.setItemGrayed("createCom",_loc1_);
            this._popupMenu.setItemGrayed("convertToBitmap",_loc1_);
            this._popupMenu.show(this.root);
         }
         else
         {
            _loc2_ = !!_loc1_?this._docContent:this._selections[0];
            _loc3_ = _loc2_ is EGGroup;
            _loc4_ = _loc3_ && !EGGroup(_loc2_).advanced;
            this._transitionMenu.setItemGrayed("xy",_loc4_);
            this._transitionMenu.setItemGrayed("size",_loc3_);
            this._transitionMenu.setItemGrayed("alpha",_loc4_);
            this._transitionMenu.setItemGrayed("rotation",_loc3_);
            this._transitionMenu.setItemGrayed("visible",_loc4_);
            this._transitionMenu.setItemGrayed("scale",_loc3_);
            this._transitionMenu.setItemGrayed("skew",_loc3_);
            this._transitionMenu.setItemGrayed("color",!(_loc2_ is EIColorGear));
            this._transitionMenu.setItemGrayed("animation",!(_loc2_ is EIAnimationGear));
            this._transitionMenu.setItemGrayed("pivot",_loc3_);
            this._transitionMenu.setItemGrayed("trans",!(_loc2_ is EGComponent));
            this._transitionMenu.setItemGrayed("sound",_loc3_);
            this._transitionMenu.setItemGrayed("shake",_loc3_);
            this._transitionMenu.setItemGrayed("colorFilter",_loc3_);
            this._transitionMenu.show(this.root);
         }
      }
      
      private function __drop(param1:DropEvent) : void
      {
         if(!(param1.source is LibPanel) && !(param1.source is ComDocument))
         {
            return;
         }
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         this.dropObjects(param1.sourceData,{"dropPos":this.getMousePos()});
      }
      
      public function dropObjects(param1:Object, param2:Object = null) : Array
      {
         var _loc8_:Boolean = false;
         var _loc9_:EGObject = null;
         var _loc13_:Object = null;
         var _loc14_:EPackageItem = null;
         var _loc15_:EGTextField = null;
         if(param2 == null)
         {
            param2 = {};
         }
         var _loc3_:Point = param2.dropPos;
         var _loc4_:int = param2.insertIndex == undefined?-1:int(param2.insertIndex);
         var _loc5_:String = param2.names;
         var _loc6_:String = param2.newId;
         this.clearSelection();
         var _loc7_:int = param1.length;
         if(_loc3_ == null)
         {
            _loc3_ = this.getCenterPos();
            _loc8_ = true;
         }
         var _loc10_:Array = [];
         var _loc11_:Array = [];
         var _loc12_:int = 0;
         for(; _loc12_ < _loc7_; _loc12_++)
         {
            _loc13_ = param1[_loc12_];
            if(_loc13_ is EPackageItem)
            {
               _loc14_ = EPackageItem(_loc13_);
               if(_loc14_.type == EPackageItem.FOLDER)
               {
                  continue;
               }
               if(_loc14_.owner == this._docItem.owner && _loc14_.id == this._docItem.id)
               {
                  this._editorWindow.alert(Consts.g.text76);
                  return _loc11_;
               }
               if(_loc14_.owner != this._docContent.pkg && !_loc14_.exported)
               {
                  _loc10_.push(_loc14_.name);
                  continue;
               }
               _loc9_ = EUIObjectFactory.createObject(_loc14_,2);
               if(_loc9_ == null)
               {
                  continue;
               }
               _loc9_.aspectLocked = false;
               if(_loc7_ == 1)
               {
                  if(_loc5_ != null)
                  {
                     _loc9_.name = _loc5_;
                  }
                  if(_loc6_ != null)
                  {
                     _loc9_.id = _loc6_;
                  }
               }
               if(_loc9_ is EGComponent)
               {
                  if(EGComponent(_loc9_).initName)
                  {
                     _loc9_.name = EGComponent(_loc9_).initName;
                  }
               }
               if(_loc9_ is EGComponent && (_loc9_ as EGComponent).containsComponent(this._docItem))
               {
                  _loc9_.dispose();
                  this._editorWindow.alert(Consts.g.text76);
                  return _loc11_;
               }
               this.content_addChild(_loc9_,!!_loc8_?new Point(_loc3_.x - _loc9_.width / 2,_loc3_.y - _loc9_.height / 2):_loc3_,_loc4_);
               _loc11_.push(_loc9_);
            }
            else
            {
               _loc9_ = EUIObjectFactory.createObject2(this._docContent.pkg,String(_loc13_),2);
               if(_loc7_ == 1)
               {
                  if(_loc5_ != null)
                  {
                     _loc9_.name = _loc5_;
                  }
                  if(_loc6_ != null)
                  {
                     _loc9_.id = _loc6_;
                  }
               }
               this.clearSelection();
               if(_loc9_ is EGTextField)
               {
                  _loc15_ = EGTextField(_loc9_);
                  _loc9_.setSize(40,18);
                  _loc15_.initFrom(this._lastTextField);
                  this._lastTextField = _loc15_;
               }
               else if(_loc9_ is EGList)
               {
                  EGList(_loc9_).overflow = EOverflowConst.SCROLL;
                  _loc9_.setSize(200,300);
               }
               else if(_loc9_ is EGLoader)
               {
                  _loc9_.setSize(50,50);
               }
               else
               {
                  _loc9_.setSize(100,100);
               }
               this.content_addChild(_loc9_,!!_loc8_?new Point(_loc3_.x - _loc9_.width / 2,_loc3_.y - _loc9_.height / 2):_loc3_,_loc4_);
               _loc11_.push(_loc9_);
            }
            if(_loc4_ != -1)
            {
               _loc4_++;
            }
            _loc3_.x = _loc3_.x + 50;
            _loc3_.y = _loc3_.y + 50;
         }
         if(_loc10_.length)
         {
            this._editorWindow.alert(Consts.g.text12 + ":\n" + _loc10_.toString());
         }
         this.requestFocus();
         return _loc11_;
      }
      
      private function content_addChild(param1:EGObject, param2:Point, param3:int) : void
      {
         if(this._selectingObject)
         {
            return;
         }
         if(param2 == null)
         {
            param2 = this.getCenterPos();
         }
         param1.x = param2.x;
         param1.y = param2.y;
         if(param3 == -1)
         {
            if(this._group)
            {
               param3 = this._docContent.getGroupTopIndex(this._group) + 1;
            }
            else
            {
               param3 = this._docContent.numChildren;
            }
         }
         else if(param3 < 0)
         {
            param3 = 0;
         }
         else if(param3 > this._docContent.numChildren)
         {
            param3 = this._docContent.numChildren;
         }
         this._docContent.addChildAt(param1,param3);
         param1.groupId = !!this._group?this._group.id:null;
         this._actionHistory.action_childAdd(param1);
         this.addSelection(param1);
         this.setUpdateChildrenPanelFlag();
      }
      
      public function content_removeChild(param1:EGObject) : void
      {
         var _loc3_:EGObject = null;
         var _loc5_:XML = null;
         var _loc6_:XML = null;
         var _loc2_:int = this._docContent.numChildren;
         var _loc4_:int = 0;
         while(_loc4_ < _loc2_)
         {
            _loc3_ = this._docContent.getChildAt(_loc4_);
            if(_loc3_.relations.hasTarget(param1))
            {
               _loc5_ = _loc3_.relations.toXML();
               _loc3_.relations.removeTarget(param1);
               _loc6_ = _loc3_.relations.toXML();
               this._actionHistory.action_relationSet(_loc3_,_loc5_,_loc6_);
            }
            _loc4_++;
         }
         if(this._docContent.relations.hasTarget(param1))
         {
            _loc5_ = this._docContent.relations.toXML();
            this._docContent.relations.removeTarget(param1);
            _loc6_ = this._docContent.relations.toXML();
            this._actionHistory.action_relationSet(this._docContent,_loc5_,_loc6_);
         }
         this._actionHistory.action_childDelete(param1);
         this._docContent.removeChild(param1);
         this.setUpdateChildrenPanelFlag();
      }
      
      public function onControllerSwitched(param1:EController) : void
      {
         this.setUpdateFlag();
         this.updateCanvasSize();
         var _loc2_:EGGroup = this._group;
         var _loc3_:int = 0;
         var _loc4_:int = -1;
         while(_loc2_ != null)
         {
            _loc3_++;
            if(!_loc2_.finalVisible)
            {
               _loc4_ = _loc3_;
            }
            _loc2_ = _loc2_.groupInst;
         }
         if(_loc4_ != -1)
         {
            this.closeGroup(_loc4_);
         }
      }
      
      public function sideScrollTest(param1:int, param2:int, param3:Point) : int
      {
         var _loc5_:Number = NaN;
         var _loc6_:int = 0;
         var _loc4_:* = 0;
         if(parent.displayObject.mouseX < autoScrollLeft && param1 < 0)
         {
            _loc5_ = parent.scrollPane.posX;
            parent.scrollPane.posX = parent.scrollPane.posX - autoScrollStep;
            _loc6_ = _loc5_ - parent.scrollPane.posX;
            if(_loc6_ != 0)
            {
               param3.x = param3.x - _loc6_ / this._container.scaleX;
               _loc4_ = _loc4_ | 1;
            }
         }
         if(parent.displayObject.mouseX > parent.width - autoScrollLeft - 20 && param1 > 0)
         {
            _loc5_ = parent.scrollPane.posX;
            parent.scrollPane.posX = parent.scrollPane.posX + autoScrollStep;
            _loc6_ = _loc5_ - parent.scrollPane.posX;
            if(_loc6_ != 0)
            {
               param3.x = param3.x - _loc6_ / this._container.scaleX;
               _loc4_ = _loc4_ | 2;
            }
         }
         if(parent.displayObject.mouseY < autoScrollLeft && param2 < 0)
         {
            _loc5_ = parent.scrollPane.posY;
            parent.scrollPane.posY = parent.scrollPane.posY - autoScrollStep;
            _loc6_ = _loc5_ - parent.scrollPane.posY;
            if(_loc6_ != 0)
            {
               param3.y = param3.y - _loc6_ / this._container.scaleX;
               _loc4_ = _loc4_ | 4;
            }
         }
         if(parent.displayObject.mouseY > parent.height - autoScrollLeft - 20 && param2 > 0)
         {
            _loc5_ = parent.scrollPane.posY;
            parent.scrollPane.posY = parent.scrollPane.posY + autoScrollStep;
            _loc6_ = _loc5_ - parent.scrollPane.posY;
            param3.y = param3.y - _loc6_ / this._container.scaleX;
            _loc4_ = _loc4_ | 8;
         }
         return _loc4_;
      }
      
      public function syncOutineFromRangeEditor(param1:EGObject, param2:Number, param3:Number, param4:Number, param5:Number) : void
      {
         var _loc10_:Boolean = false;
         var _loc14_:EGObject = null;
         var _loc15_:Number = NaN;
         if(this._selections.indexOf(param1) == -1)
         {
            this.clearSelection();
         }
         var _loc6_:Number = param1.x;
         var _loc7_:Number = param1.y;
         var _loc8_:Number = param1.width;
         var _loc9_:Number = param1.height;
         this.makeSelectionsFixed(true);
         var _loc11_:int = this.getOutlineLocks(param1);
         param2 = !!(_loc11_ & 1)?Number(0):Number(param1.setProperty("x",param1.x + param2) - _loc6_);
         param3 = !!(_loc11_ & 2)?Number(0):Number(param1.setProperty("y",param1.y + param3) - _loc7_);
         if(param4 != 0 || param5 != 0)
         {
            if((_loc11_ & 12) == 0)
            {
               if(param1 is EGTextField && (EGTextField(param1).autoSize != "none" && EGTextField(param1).autoSize != "shrink"))
               {
                  EGTextField(param1).setProperty("autoSize","none");
                  _loc10_ = true;
               }
            }
            param4 = !!(_loc11_ & 4)?Number(0):Number(param1.setProperty("width",param1.width + param4) - _loc8_);
            param5 = !!(_loc11_ & 8)?Number(0):Number(param1.setProperty("height",param1.height + param5) - _loc9_);
         }
         var _loc12_:int = this._selections.length;
         var _loc13_:int = 0;
         while(_loc13_ < _loc12_)
         {
            _loc14_ = this._selections[_loc13_];
            if(_loc14_ != param1)
            {
               _loc11_ = this.getOutlineLocks(_loc14_);
               _loc15_ = _loc14_.x + param2;
               if(!(_loc11_ & 1))
               {
                  _loc14_.setProperty("x",_loc15_);
               }
               _loc15_ = _loc14_.y + param3;
               if(!(_loc11_ & 2))
               {
                  _loc14_.setProperty("y",_loc15_);
               }
               if(param4 != 0 || param5 != 0)
               {
                  if((_loc11_ & 12) == 0)
                  {
                     if(_loc14_ is EGTextField && (EGTextField(_loc14_).autoSize != "none" && EGTextField(_loc14_).autoSize != "shrink"))
                     {
                        EGTextField(_loc14_).setProperty("autoSize","none");
                        _loc10_ = true;
                     }
                  }
                  _loc15_ = _loc14_.width + param4;
                  if(!(_loc11_ & 4))
                  {
                     _loc14_.setProperty("width",_loc15_);
                  }
                  _loc15_ = _loc14_.height + param5;
                  if(!(_loc11_ & 8))
                  {
                     _loc14_.setProperty("height",_loc15_);
                  }
               }
            }
            _loc13_++;
         }
         this.makeSelectionsFixed(false);
         if(_loc10_)
         {
            this.setUpdateFlag();
         }
      }
      
      private function __menuCut(param1:Event) : void
      {
         this.copySelection();
         this.deleteSelection();
      }
      
      private function __menuCopy(param1:Event) : void
      {
         this.copySelection();
      }
      
      private function __menuPaste(param1:Event) : void
      {
         this.doPaste(this._menuPos);
      }
      
      private function __menuDelete(param1:Event) : void
      {
         this.deleteSelection();
      }
      
      private function __menuSelectAll(param1:Event) : void
      {
         this.doSelectAll();
      }
      
      private function __menuUnselectAll(param1:Event) : void
      {
         this.doUnselectAll();
      }
      
      public function moveCrossGroups(param1:EGObject) : void
      {
         var _loc9_:EGObject = null;
         var _loc10_:int = 0;
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         var _loc2_:Array = this.getSortedSelectionList();
         var _loc3_:int = _loc2_.length;
         if(_loc2_.length == 0)
         {
            return;
         }
         var _loc4_:int = 0;
         while(_loc4_ < _loc3_)
         {
            if(_loc2_[_loc4_].obj == param1)
            {
               return;
            }
            _loc4_++;
         }
         var _loc5_:EGObject = _loc2_[_loc3_ - 1].obj;
         var _loc6_:EGGroup = _loc5_.groupInst;
         var _loc7_:int = this._docContent.getChildIndex(_loc5_);
         var _loc8_:int = this._docContent.getChildIndex(param1);
         if(_loc7_ > _loc8_ && param1 is EGGroup)
         {
            _loc10_ = this._docContent.numChildren;
            _loc4_ = 0;
            while(_loc4_ < _loc10_)
            {
               if(this._docContent.getChildAt(_loc4_).groupInst == param1)
               {
                  _loc8_ = _loc4_;
                  break;
               }
               _loc4_++;
            }
         }
         this.openGroup(param1.groupInst);
         if(_loc6_ != param1.groupInst)
         {
            _loc4_ = 0;
            while(_loc4_ < _loc3_)
            {
               _loc9_ = _loc2_[_loc4_].obj;
               if(_loc9_.groupInst == _loc6_)
               {
                  _loc9_.setProperty("groupId",param1.groupId);
               }
               _loc4_++;
            }
         }
         if(_loc7_ < _loc8_)
         {
            _loc4_ = 0;
            while(_loc4_ < _loc3_)
            {
               _loc9_ = _loc2_[_loc4_].obj;
               this._actionHistory.action_childIndex(_loc9_,_loc8_);
               this._docContent.setChildIndex(_loc9_,_loc8_);
               _loc4_++;
            }
         }
         else
         {
            _loc4_ = _loc3_ - 1;
            while(_loc4_ >= 0)
            {
               _loc9_ = _loc2_[_loc4_].obj;
               this._actionHistory.action_childIndex(_loc9_,_loc8_);
               this._docContent.setChildIndex(_loc9_,_loc8_);
               _loc4_--;
            }
         }
         if(_loc6_ != null)
         {
            _loc6_.update();
         }
         if(param1.groupInst != null)
         {
            param1.groupInst.update();
         }
         this.setUpdateChildrenPanelFlag();
         this.clearSelection();
         _loc4_ = 0;
         while(_loc4_ < _loc3_)
         {
            this.addSelection(_loc2_[_loc4_].obj);
            _loc4_++;
         }
      }
      
      private function __menuMoveTop(param1:Event) : void
      {
         var _loc2_:int = 0;
         var _loc6_:Object = null;
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         if(this._group)
         {
            _loc2_ = this._docContent.getGroupTopIndex(this._group);
         }
         else
         {
            _loc2_ = this._docContent.numChildren - 1;
         }
         var _loc3_:Array = this.getSortedSelectionList();
         var _loc4_:int = _loc3_.length;
         if(_loc3_.length == 0)
         {
            return;
         }
         var _loc5_:int = 0;
         while(_loc5_ < _loc4_)
         {
            _loc6_ = _loc3_[_loc5_];
            this._actionHistory.action_childIndex(_loc6_.obj,_loc2_);
            this._docContent.setChildIndex(_loc6_.obj,_loc2_);
            _loc5_++;
         }
         this.setUpdateChildrenPanelFlag();
      }
      
      private function __menuMoveUp(param1:Event) : void
      {
         var _loc2_:int = 0;
         var _loc6_:Object = null;
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         if(this._group)
         {
            _loc2_ = this._docContent.getGroupTopIndex(this._group);
         }
         else
         {
            _loc2_ = this._docContent.numChildren - 1;
         }
         var _loc3_:Array = this.getSortedSelectionList();
         var _loc4_:int = _loc3_.length;
         if(_loc3_.length == 0 || _loc3_[_loc4_ - 1].index == _loc2_)
         {
            return;
         }
         var _loc5_:int = _loc4_ - 1;
         while(_loc5_ >= 0)
         {
            _loc6_ = _loc3_[_loc5_];
            this._actionHistory.action_childIndex(_loc6_.obj,_loc6_.index + 1);
            this._docContent.setChildIndex(_loc6_.obj,_loc6_.index + 1);
            _loc5_--;
         }
         this.setUpdateChildrenPanelFlag();
      }
      
      private function __menuMoveDown(param1:Event) : void
      {
         var _loc2_:int = 0;
         var _loc6_:Object = null;
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         if(this._group)
         {
            _loc2_ = this._docContent.getGroupBottomIndex(this._group);
         }
         else
         {
            _loc2_ = 0;
         }
         var _loc3_:Array = this.getSortedSelectionList();
         var _loc4_:int = _loc3_.length;
         if(_loc3_.length == 0 || _loc3_[0].index == _loc2_)
         {
            return;
         }
         var _loc5_:int = 0;
         while(_loc5_ < _loc4_)
         {
            _loc6_ = _loc3_[_loc5_];
            this._actionHistory.action_childIndex(_loc6_.obj,_loc6_.index - 1);
            this._docContent.setChildIndex(_loc6_.obj,_loc6_.index - 1);
            _loc5_++;
         }
         this.setUpdateChildrenPanelFlag();
      }
      
      private function __menuMoveBottom(param1:Event) : void
      {
         var _loc2_:int = 0;
         var _loc6_:Object = null;
         if(this._docContent.editingTransition != null)
         {
            return;
         }
         if(this._group)
         {
            _loc2_ = this._docContent.getGroupBottomIndex(this._group);
         }
         else
         {
            _loc2_ = 0;
         }
         var _loc3_:Array = this.getSortedSelectionList();
         var _loc4_:int = _loc3_.length;
         if(_loc3_.length == 0)
         {
            return;
         }
         var _loc5_:int = _loc4_ - 1;
         while(_loc5_ >= 0)
         {
            _loc6_ = _loc3_[_loc5_];
            this._actionHistory.action_childIndex(_loc6_.obj,_loc2_);
            this._docContent.setChildIndex(_loc6_.obj,_loc2_);
            _loc5_--;
         }
         this.setUpdateChildrenPanelFlag();
      }
      
      private function __menuShowInLib(param1:Event) : void
      {
         var _loc2_:EGObject = this.getSelection();
         if(!_loc2_)
         {
            _loc2_ = this._docContent;
         }
         if(_loc2_ && _loc2_.packageItem)
         {
            this._docItem.owner.project.editorWindow.mainPanel.libPanel.highlightItem(_loc2_.packageItem);
         }
      }
      
      private function __menuExchange(param1:Event) : void
      {
         var _loc2_:EGObject = this.getSelection();
         ExchangeDialog(this._docItem.owner.project.editorWindow.getDialog(ExchangeDialog)).open(_loc2_);
      }
      
      private function __menuCreateCom(param1:Event) : void
      {
         var left:int = 0;
         var top:int = 0;
         var i:int = 0;
         var j:int = 0;
         var insertIndex:int = 0;
         var cxml:XML = null;
         var pns:Vector.<String> = null;
         var newName:String = null;
         var newId:String = null;
         var obj:EGObject = null;
         var cc:EController = null;
         var evt:Event = param1;
         var ssl:Array = this.getSortedSelectionList();
         if(ssl.length == 0)
         {
            return;
         }
         left = int.MAX_VALUE;
         top = int.MAX_VALUE;
         var right:int = int.MIN_VALUE;
         var bottom:int = int.MIN_VALUE;
         var cnt:int = ssl.length;
         var sels:Vector.<EGObject> = new Vector.<EGObject>();
         i = 0;
         while(i < cnt)
         {
            obj = ssl[i].obj;
            sels.push(obj);
            if(obj.x < left)
            {
               left = obj.x;
            }
            if(obj.y < top)
            {
               top = obj.y;
            }
            if(obj.x + obj.width > right)
            {
               right = obj.x + obj.width;
            }
            if(obj.y + obj.height > bottom)
            {
               bottom = obj.y + obj.height;
            }
            i++;
         }
         insertIndex = ssl[0].index;
         var xml:XML = <component/>;
         xml.@size = right - left + "," + (bottom - top);
         var ccCnt:int = this._docContent.controllers.length;
         i = 0;
         while(i < ccCnt)
         {
            cc = this._docContent.controllers[i];
            j = 0;
            while(j < cnt)
            {
               obj = sels[j];
               if(obj.checkGearsController(cc))
               {
                  cxml = cc.toXML();
                  if(cxml)
                  {
                     xml.appendChild(cxml);
                  }
                  break;
               }
               j++;
            }
            i++;
         }
         var dxml:XML = <displayList/>;
         xml.appendChild(dxml);
         i = 0;
         while(i < cnt)
         {
            obj = sels[i];
            cxml = obj.toXML();
            cxml.@xy = int(obj.x - left) + "," + int(obj.y - top);
            if(obj.groupInst != null && sels.indexOf(obj.groupInst) == -1)
            {
               delete cxml.@group;
            }
            dxml.appendChild(cxml);
            i++;
         }
         newName = ssl[0].obj.name;
         newId = ssl[0].obj.id;
         CreateComDialog(this._editorWindow.getDialog(CreateComDialog)).open(xml,function(param1:EPackageItem):void
         {
            deleteSelection();
            dropObjects([param1],{
               "dropPos":new Point(left,top),
               "insertIndex":insertIndex,
               "newName":newName,
               "newId":newId
            });
         });
      }
      
      private function __menuConvertToBitmap(param1:Event) : void
      {
         var _loc8_:int = 0;
         var _loc9_:int = 0;
         var _loc10_:Rectangle = null;
         var _loc11_:EGObject = null;
         var _loc2_:Array = this.getSortedSelectionList();
         if(_loc2_.length == 0)
         {
            return;
         }
         var _loc3_:int = int.MAX_VALUE;
         var _loc4_:int = int.MAX_VALUE;
         var _loc5_:int = int.MIN_VALUE;
         var _loc6_:int = int.MIN_VALUE;
         var _loc7_:int = _loc2_.length;
         _loc8_ = 0;
         while(_loc8_ < _loc7_)
         {
            _loc11_ = _loc2_[_loc8_].obj;
            if(!(_loc11_ is EGGroup))
            {
               if(_loc10_ == null)
               {
                  _loc10_ = _loc11_.displayObject.getBounds(this._docContent.displayObject);
               }
               else
               {
                  _loc10_ = _loc10_.union(_loc11_.displayObject.getBounds(this._docContent.displayObject));
               }
            }
            _loc8_++;
         }
         var _loc12_:BitmapData = new BitmapData(_loc10_.width,_loc10_.height,true,0);
         var _loc13_:Matrix = new Matrix();
         _loc8_ = 0;
         while(_loc8_ < _loc7_)
         {
            _loc11_ = _loc2_[_loc8_].obj;
            if(!(_loc11_ is EGGroup))
            {
               _loc13_.identity();
               _loc13_.translate(_loc11_.x - _loc10_.x,_loc11_.y - _loc10_.y);
               _loc11_.displayObject.drawTo(_loc12_,_loc13_);
            }
            _loc8_++;
         }
         var _loc14_:ByteArray = _loc12_.encode(_loc12_.rect,new PNGEncoderOptions());
         var _loc15_:File = new File(this._editorWindow.project.objsPath + "/temp");
         if(!_loc15_.exists)
         {
            _loc15_.createDirectory();
         }
         var _loc16_:* = _loc2_[0].obj.name;
         if(!_loc16_)
         {
            _loc16_ = "Bitmap.png";
         }
         else
         {
            _loc16_ = _loc16_ + ".png";
         }
         var _loc17_:File = _loc15_.resolvePath(_loc16_);
         UtilsFile.saveBytes(_loc17_,_loc14_);
         var _loc18_:int = _loc2_[0].index;
         this.deleteSelection();
         var _loc19_:String = _loc2_[0].obj.name;
         var _loc20_:String = _loc2_[0].obj.id;
         var _loc21_:Object = {
            "dropTarget":"document",
            "dropPos":_loc10_.topLeft,
            "crop":false,
            "insertIndex":_loc18_,
            "newName":_loc19_,
            "newId":_loc20_
         };
         this._editorWindow.mainPanel.importResources([_loc17_],this._docContent.pkg,["/"],_loc21_);
      }
      
      public function undo() : void
      {
         if(this._selectingObject)
         {
            return;
         }
         if(this._actionHistory.undo())
         {
            this.setUpdateFlag();
            this.setUpdateChildrenPanelFlag();
         }
      }
      
      public function redo() : void
      {
         if(this._selectingObject)
         {
            return;
         }
         if(this._actionHistory.redo())
         {
            this.setUpdateFlag();
            this.setUpdateChildrenPanelFlag();
         }
      }
      
      public function makeGroup() : void
      {
         var _loc3_:int = 0;
         var _loc6_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         this.__menuMoveTop(null);
         var _loc2_:Vector.<EGObject> = new Vector.<EGObject>().concat(this._selections);
         this.clearSelection();
         if(this._group)
         {
            _loc3_ = this._docContent.getGroupTopIndex(this._group) + 1;
         }
         else
         {
            _loc3_ = this._docContent.numChildren;
         }
         var _loc4_:EGGroup = EUIObjectFactory.createObject2(this._docContent.pkg,"group",2) as EGGroup;
         this._docContent.addChildAt(_loc4_,_loc3_);
         if(this._group)
         {
            _loc4_.groupId = this._group.id;
         }
         this._actionHistory.action_childAdd(_loc4_);
         var _loc5_:int = 0;
         while(_loc5_ < _loc1_)
         {
            _loc6_ = _loc2_[_loc5_];
            _loc6_.setProperty("groupId",_loc4_.id);
            _loc5_++;
         }
         _loc4_.updateImmdediately();
         this.addSelection(_loc4_);
         this.setUpdateChildrenPanelFlag();
      }
      
      public function ungroup() : void
      {
         var _loc1_:EGObject = this.getSelection();
         if(!(_loc1_ is EGGroup))
         {
            return;
         }
         var _loc2_:EGGroup = EGGroup(_loc1_);
         this.removeSelection(_loc2_);
         var _loc3_:String = _loc2_.groupId;
         var _loc4_:int = this._docContent.numChildren;
         var _loc5_:int = 0;
         while(_loc5_ < _loc4_)
         {
            _loc1_ = this._docContent.getChildAt(_loc5_);
            if(_loc1_.groupId == _loc2_.id)
            {
               _loc1_.setProperty("groupId",_loc3_);
               this.addSelection(_loc1_);
            }
            _loc5_++;
         }
         this.content_removeChild(_loc2_);
      }
      
      public function get openedGroup() : EGGroup
      {
         return this._group;
      }
      
      public function openGroup(param1:EGGroup) : void
      {
         var _loc2_:EGGroup = null;
         if(!param1)
         {
            this.closeGroup(int.MAX_VALUE);
            return;
         }
         if(this._group)
         {
            if(this._group != param1.groupInst)
            {
               _loc2_ = this._group;
               while(_loc2_)
               {
                  _loc2_.opened = false;
                  _loc2_ = _loc2_.groupInst;
               }
            }
         }
         this._group = param1;
         this._group.opened = true;
         this._docContent.updateDisplayList();
         this.clearSelection(true);
         this._editPanel.updateGroupPathList(this._group);
      }
      
      public function closeGroup(param1:int = 1) : void
      {
         var _loc2_:EGGroup = null;
         if(!this._group || param1 < 1)
         {
            return;
         }
         var _loc3_:int = 0;
         while(_loc3_ < param1)
         {
            if(this._group.needUpdate)
            {
               this._group.updateImmdediately();
            }
            this._group.opened = false;
            _loc2_ = this._group;
            this._group = this._group.groupInst;
            if(_loc2_.parent && _loc2_.empty)
            {
               this.content_removeChild(_loc2_);
            }
            if(!this._group)
            {
               break;
            }
            _loc3_++;
         }
         this.clearSelection(true);
         if(_loc2_.parent && _loc2_.finalVisible)
         {
            this.addSelection(_loc2_,true);
         }
         this._docContent.updateDisplayList();
         this._editPanel.updateGroupPathList(this._group);
      }
      
      public function notifyGroupRemoved(param1:EGGroup) : void
      {
         while(this._group && (this._group == param1 || this._group.inGroup(param1)))
         {
            this.closeGroup();
         }
      }
      
      public function handleKeyDownEvent(param1:KeyboardEvent) : void
      {
         if(!this._docContent)
         {
            return;
         }
         var _loc2_:String = String.fromCharCode(param1.charCode).toLowerCase();
         switch(param1.keyCode)
         {
            case 46:
            case 8:
               if(this._docContent.editingTransition == null)
               {
                  this.doDelete();
               }
               return;
            case Keyboard.F8:
               if(this._docContent.editingTransition == null)
               {
                  this.__menuCreateCom(null);
               }
               return;
            default:
               if(param1.ctrlKey && !param1.altKey)
               {
                  switch(_loc2_)
                  {
                     case "c":
                        if(this._docContent.editingTransition == null)
                        {
                           this.doCopy();
                        }
                        break;
                     case "x":
                        if(this._docContent.editingTransition == null)
                        {
                           this.doCut();
                        }
                        break;
                     case "v":
                        if(this._docContent.editingTransition == null)
                        {
                           if(param1.shiftKey)
                           {
                              this.doPaste(null);
                           }
                           else
                           {
                              this.doPaste(null,true);
                           }
                        }
                        break;
                     case "a":
                        if(this._docContent.editingTransition == null)
                        {
                           if(param1.shiftKey)
                           {
                              this.doUnselectAll();
                           }
                           else
                           {
                              this.doSelectAll();
                           }
                        }
                        break;
                     case "z":
                        this.undo();
                        break;
                     case "y":
                        this.redo();
                        break;
                     case "g":
                        if(this._docContent.editingTransition == null)
                        {
                           if(param1.shiftKey)
                           {
                              this.ungroup();
                           }
                           else
                           {
                              this.makeGroup();
                           }
                        }
                        break;
                     case "d":
                        if(this._docContent.editingTransition != null)
                        {
                           this._editPanel.timelinePanel.removeFrame();
                        }
                        break;
                     case "k":
                        if(this._docContent.editingTransition != null)
                        {
                           this._editPanel.timelinePanel.setKeyFrame();
                        }
                        return;
                     case "i":
                        if(this._docContent.editingTransition != null)
                        {
                           this._editPanel.timelinePanel.insertFrame();
                        }
                        return;
                  }
               }
               else
               {
                  switch(_loc2_)
                  {
                     case " ":
                        this._editPanel.editType = 1;
                        return;
                     case "v":
                        this._editPanel.editType = 0;
                        return;
                  }
               }
               return;
         }
      }
      
      public function handleKeyUpEvent(param1:KeyboardEvent) : void
      {
         if(param1.charCode == 32)
         {
            if(this._editPanel.editType == 1)
            {
               this._editPanel.editType = 0;
            }
            return;
         }
      }
      
      public function handleArrowKey(param1:int, param2:Boolean, param3:Boolean) : void
      {
         if(param2)
         {
            if(param1 == 1)
            {
               this.__menuMoveUp(null);
            }
            else if(param1 == 5)
            {
               this.__menuMoveDown(null);
            }
            else if(param1 == 3)
            {
               this.__menuMoveTop(null);
            }
            else if(param1 == 7)
            {
               this.__menuMoveBottom(null);
            }
         }
         else if(param3)
         {
            this.moveSelection(OFFSET[param1 * 2] * 10,OFFSET[param1 * 2 + 1] * 10);
         }
         else
         {
            this.moveSelection(OFFSET[param1 * 2],OFFSET[param1 * 2 + 1]);
         }
      }
      
      public function setTimelineUpdateFlag() : void
      {
         this._docContent.editingTransition.setCurFrame(this._editPanel.timelinePanel.head);
         GTimers.inst.callLater(this._docItem.owner.project.editorWindow.mainPanel.propsPanelList.refresh);
      }
      
      public function setUpdateFlag() : void
      {
         GTimers.inst.callLater(this._docItem.owner.project.editorWindow.mainPanel.propsPanelList.refresh);
      }
      
      public function setUpdateChildrenPanelFlag() : void
      {
         this._editorWindow.mainPanel.childrenPanel.update(null);
      }
      
      public function setChildrenPanelSelection() : void
      {
         this._editorWindow.mainPanel.childrenPanel.syncSelection();
      }
      
      public function startSelectingObject(param1:EGObject) : void
      {
         if(this._selections.length == 0)
         {
            this._emptySelectionBeforeSelect = true;
         }
         else
         {
            this._emptySelectionBeforeSelect = false;
            this.clearSelection();
         }
         this._selectingObject = true;
         this._actionHistory.enabled = false;
         this._groupBeforeSelect = this._group;
         if(param1)
         {
            if(param1 == this._docContent)
            {
               this.closeGroup(int.MAX_VALUE);
            }
            else
            {
               this.openGroup(param1.groupInst);
               this.addSelection(param1);
            }
         }
         this.setUpdateFlag();
      }
      
      public function finishSelectingObject() : void
      {
         if(!this._selectingObject)
         {
            return;
         }
         this._selectingObject = false;
         this.openGroup(this._groupBeforeSelect);
         this.clearSelection();
         this._actionHistory.enabled = true;
         if(!this._emptySelectionBeforeSelect)
         {
            this._actionHistory.undo();
         }
         this.setUpdateFlag();
      }
      
      public function get isSelectingObject() : Boolean
      {
         return this._selectingObject;
      }
      
      public function startEditingTransition(param1:ETransition) : void
      {
         if(this._docContent.editingTransition != null)
         {
            this.finishEditingTransition();
         }
         this._docContent.editingTransition = param1;
         this._actionHistory.enterTransition(param1);
         this.closeGroup(int.MAX_VALUE);
         this._docContent.takeSnapshot();
         this._docContent.editingTransition.validate();
         this._editPanel.timelinePanel.show(this);
         this._editPanel.updateControllerPanel();
         this._editPanel.updateTransitionListPanel();
         this._editPanel.enterEditingTrans();
         this.setUpdateFlag();
      }
      
      public function finishEditingTransition() : void
      {
         if(this._docContent.editingTransition == null)
         {
            return;
         }
         this._editPanel.timelinePanel.hide(this);
         this._docContent.editingTransition = null;
         this._docContent.readSnapshot();
         this._actionHistory.leaveTransition();
         this._editPanel.updateControllerPanel();
         this._editPanel.updateTransitionListPanel();
         this._editPanel.leaveEditingTrans();
         this.setUpdateFlag();
      }
      
      public function get editingTransition() : ETransition
      {
         return this._docContent.editingTransition;
      }
      
      public function getOutlineLocks(param1:EGObject) : int
      {
         var _loc3_:ETransitionItem = null;
         var _loc2_:* = 0;
         if(param1.relations.widthLocked)
         {
            _loc2_ = _loc2_ | 4;
         }
         if(param1.relations.heightLocked)
         {
            _loc2_ = _loc2_ | 8;
         }
         if(this._docContent.editingTransition)
         {
            _loc3_ = this._docContent.editingTransition.findCurItem(param1.id,"XY");
            if(!_loc3_)
            {
               _loc2_ = _loc2_ | 3;
            }
            else
            {
               if(!_loc3_.value.aEnabled)
               {
                  _loc2_ = _loc2_ | 1;
               }
               if(!_loc3_.value.bEnabled)
               {
                  _loc2_ = _loc2_ | 2;
               }
            }
            _loc3_ = this._docContent.editingTransition.findCurItem(param1.id,"Size");
            if(!_loc3_)
            {
               _loc2_ = _loc2_ | 12;
            }
            else
            {
               if(!_loc3_.value.aEnabled)
               {
                  _loc2_ = _loc2_ | 4;
               }
               if(!_loc3_.value.bEnabled)
               {
                  _loc2_ = _loc2_ | 8;
               }
            }
            return _loc2_;
         }
         return _loc2_;
      }
      
      public function arrangeLeft() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",0);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].x;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",_loc3_);
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeRight() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",this._docContent.width - _loc5_.width);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].x + this._selections[0].width;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",_loc3_ - _loc5_.width);
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeCenter() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",int((this._docContent.width - _loc5_.width) / 2));
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].x + this._selections[0].width / 2;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 1))
            {
               _loc5_.setProperty("x",int(_loc3_ - _loc5_.width / 2));
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeTop() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",0);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].y;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",_loc3_);
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeBottom() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",this._docContent.height - _loc5_.height);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].y + this._selections[0].height;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",_loc3_ - _loc5_.height);
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeMiddle() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",int((this._docContent.height - _loc5_.height) / 2));
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].y + this._selections[0].height / 2;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 2))
            {
               _loc5_.setProperty("y",int(_loc3_ - _loc5_.height / 2));
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeSameWidth() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 4))
            {
               _loc5_.setProperty("width",this._docContent.width);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].width;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 4))
            {
               _loc3_ = _loc5_.setProperty("width",_loc3_);
               if(_loc5_.aspectLocked)
               {
                  _loc5_.setProperty("height",int(_loc3_ / _loc5_.aspectRatio));
               }
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function arrangeSameHeight() : void
      {
         var _loc2_:int = 0;
         var _loc5_:EGObject = null;
         var _loc1_:int = this._selections.length;
         if(_loc1_ == 0)
         {
            return;
         }
         if(_loc1_ == 1)
         {
            _loc5_ = this._selections[0];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 8))
            {
               _loc5_.setProperty("height",this._docContent.height);
            }
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc3_:int = this._selections[0].height;
         var _loc4_:int = 1;
         while(_loc4_ < _loc1_)
         {
            _loc5_ = this._selections[_loc4_];
            _loc2_ = this.getOutlineLocks(_loc5_);
            if(!(_loc2_ & 8))
            {
               _loc3_ = _loc5_.setProperty("height",_loc3_);
               if(_loc5_.aspectLocked)
               {
                  _loc5_.setProperty("width",int(_loc3_ * _loc5_.aspectRatio));
               }
            }
            _loc4_++;
         }
         this.makeSelectionsFixed(false);
      }
      
      public function getSelectionHGap() : int
      {
         var _loc2_:int = 0;
         var _loc3_:EGObject = null;
         var _loc4_:Array = null;
         var _loc5_:int = 0;
         var _loc6_:int = 0;
         var _loc1_:int = this._selections.length;
         if(_loc1_ > 1)
         {
            _loc4_ = [];
            _loc2_ = 0;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = this._selections[_loc2_];
               _loc4_.push(_loc3_);
               _loc2_++;
            }
            _loc4_.sortOn("y",Array.NUMERIC);
            _loc5_ = 0;
            _loc2_ = 1;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = _loc4_[_loc2_];
               _loc6_ = _loc3_.y - (_loc4_[_loc2_ - 1].y + _loc4_[_loc2_ - 1].height);
               if(_loc6_ > 0)
               {
                  _loc5_ = _loc6_;
                  break;
               }
               _loc2_++;
            }
            return _loc5_;
         }
         return 0;
      }
      
      public function getSelectionVGap() : int
      {
         var _loc2_:int = 0;
         var _loc3_:EGObject = null;
         var _loc4_:Array = null;
         var _loc5_:int = 0;
         var _loc6_:int = 0;
         var _loc1_:int = this._selections.length;
         if(_loc1_ > 1)
         {
            _loc4_ = [];
            _loc2_ = 0;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = this._selections[_loc2_];
               _loc4_.push(_loc3_);
               _loc2_++;
            }
            _loc4_.sortOn("x",Array.NUMERIC);
            _loc5_ = 0;
            _loc2_ = 1;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = _loc4_[_loc2_];
               _loc6_ = _loc3_.x - (_loc4_[_loc2_ - 1].x + _loc4_[_loc2_ - 1].width);
               if(_loc6_ > 0)
               {
                  _loc5_ = _loc6_;
                  break;
               }
               _loc2_++;
            }
            return _loc5_;
         }
         return 0;
      }
      
      public function getSelectionCols() : int
      {
         var _loc2_:int = 0;
         var _loc3_:EGObject = null;
         var _loc4_:Array = null;
         var _loc5_:int = 0;
         var _loc1_:int = this._selections.length;
         if(_loc1_ > 1)
         {
            _loc4_ = [];
            _loc2_ = 0;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = this._selections[_loc2_];
               _loc4_.push(_loc3_);
               _loc2_++;
            }
            _loc4_.sortOn("y",Array.NUMERIC);
            _loc2_ = 1;
            while(_loc2_ < _loc1_)
            {
               _loc3_ = _loc4_[_loc2_];
               _loc5_ = _loc3_.y - (_loc4_[_loc2_ - 1].y + _loc4_[_loc2_ - 1].height);
               if(_loc5_ > 0)
               {
                  return _loc2_;
               }
               _loc2_++;
            }
            return _loc2_;
         }
         return 1;
      }
      
      public function doArrangeCustom(param1:int, param2:int, param3:int, param4:int) : void
      {
         var _loc6_:int = 0;
         var _loc7_:int = 0;
         var _loc8_:EGObject = null;
         var _loc10_:int = 0;
         var _loc11_:int = 0;
         var _loc12_:int = 0;
         var _loc13_:Array = null;
         var _loc5_:int = this._selections.length;
         if(_loc5_ <= 1)
         {
            return;
         }
         this.makeSelectionsFixed(true);
         var _loc9_:Array = [];
         if(param1 == 0)
         {
            _loc7_ = 0;
            while(_loc7_ < _loc5_)
            {
               _loc8_ = this._selections[_loc7_];
               _loc9_.push(_loc8_);
               _loc7_++;
            }
            _loc9_.sortOn("y",Array.NUMERIC);
            _loc7_ = 1;
            while(_loc7_ < _loc5_)
            {
               _loc8_ = _loc9_[_loc7_];
               _loc6_ = this.getOutlineLocks(_loc8_);
               if(!(_loc6_ & 2))
               {
                  _loc8_.setProperty("y",int(_loc9_[_loc7_ - 1].y + _loc9_[_loc7_ - 1].height + param4));
               }
               _loc7_++;
            }
         }
         else if(param1 == 1)
         {
            _loc7_ = 0;
            while(_loc7_ < _loc5_)
            {
               _loc8_ = this._selections[_loc7_];
               _loc9_.push(_loc8_);
               _loc7_++;
            }
            _loc9_.sortOn("x",Array.NUMERIC);
            _loc7_ = 1;
            while(_loc7_ < _loc5_)
            {
               _loc8_ = _loc9_[_loc7_];
               _loc6_ = this.getOutlineLocks(_loc8_);
               if(!(_loc6_ & 1))
               {
                  _loc8_.setProperty("x",int(_loc9_[_loc7_ - 1].x + _loc9_[_loc7_ - 1].width + param3));
               }
               _loc7_++;
            }
         }
         else
         {
            if(param2 == 0)
            {
               param2 = 1;
            }
            _loc7_ = 0;
            while(_loc7_ < _loc5_)
            {
               _loc8_ = this._selections[_loc7_];
               _loc9_.push(_loc8_);
               _loc7_++;
            }
            _loc9_.sortOn("x",Array.NUMERIC);
            _loc10_ = _loc9_[0].x;
            _loc9_.sortOn("y",Array.NUMERIC);
            _loc11_ = _loc9_[0].y;
            do
            {
               _loc13_ = _loc9_.slice(0,param2);
               _loc13_.sortOn("x",Array.NUMERIC);
               _loc12_ = 0;
               _loc7_ = 0;
               while(_loc7_ < param2)
               {
                  _loc8_ = _loc13_[_loc7_];
                  if(!_loc8_)
                  {
                     break;
                  }
                  _loc6_ = this.getOutlineLocks(_loc8_);
                  if(!(_loc6_ & 1))
                  {
                     if(_loc7_ == 0)
                     {
                        _loc8_.setProperty("x",_loc10_);
                     }
                     else
                     {
                        _loc8_.setProperty("x",_loc13_[_loc7_ - 1].x + _loc13_[_loc7_ - 1].width + param3);
                     }
                  }
                  if(!(_loc6_ & 2))
                  {
                     _loc8_.setProperty("y",_loc11_);
                  }
                  if(_loc8_.height > _loc12_)
                  {
                     _loc12_ = _loc8_.height;
                  }
                  _loc7_++;
               }
               if(_loc7_ != param2)
               {
                  break;
               }
               _loc11_ = _loc11_ + (_loc12_ + param4);
               _loc9_.splice(0,param2);
            }
            while(_loc9_.length != 0);
            
         }
         this.makeSelectionsFixed(false);
      }
      
      public function onBgColorChanged() : void
      {
         if(parent != null)
         {
            this.drawBackground();
         }
         else
         {
            this._bgColorChanged = true;
         }
      }
      
      public function onViewScaleChanged() : void
      {
         var _loc5_:RangeEditor = null;
         var _loc6_:EUISprite = null;
         var _loc1_:Number = this._docItem.owner.project.editorWindow.mainPanel.viewScale;
         var _loc2_:Number = this._container.scaleX;
         if(_loc1_ == _loc2_)
         {
            return;
         }
         this._container.scaleX = _loc1_;
         this._container.scaleY = _loc1_;
         this._selContainer.scaleX = _loc1_;
         this._selContainer.scaleY = _loc1_;
         this._savedScrollPercX = parent.scrollPane.percX;
         this._savedScrollPercY = parent.scrollPane.percY;
         this.updateCanvasSize(true);
         var _loc3_:int = this._selContainer.numChildren;
         var _loc4_:int = 0;
         while(_loc4_ < _loc3_)
         {
            _loc5_ = RangeEditor(this._selContainer.getChildAt(_loc4_));
            _loc5_.onViewScaleChanged();
            _loc4_++;
         }
         _loc3_ = this._docContent.numChildren;
         _loc4_ = 0;
         while(_loc4_ < _loc3_)
         {
            _loc6_ = this._docContent.getChildAt(_loc4_).displayObject;
            _loc6_.onViewScaleChanged();
            _loc4_++;
         }
         parent.scrollPane.percX = this._savedScrollPercX;
         parent.scrollPane.percY = this._savedScrollPercY;
      }
      
      private function __docContainerSizeChanged() : void
      {
         this.updateCanvasSize(true);
      }
      
      private function __contentSizeChanged() : void
      {
         this.updateCanvasSize(true);
      }
      
      private function __contentXYChanged() : void
      {
         var _loc3_:RangeEditor = null;
         this.updateCanvasSize(false);
         var _loc1_:int = this._selContainer.numChildren;
         var _loc2_:int = 0;
         while(_loc2_ < _loc1_)
         {
            _loc3_ = RangeEditor(this._selContainer.getChildAt(_loc2_));
            _loc3_.synEditorRange();
            _loc2_++;
         }
      }
      
      private function __menuTransXY(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"XY");
      }
      
      private function __menuTransSize(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Size");
      }
      
      private function __menuTransAlpha(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Alpha");
      }
      
      private function __menuTransRotation(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Rotation");
      }
      
      private function __menuTransScale(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Scale");
      }
      
      private function __menuTransSkew(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Skew");
      }
      
      private function __menuTransColor(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Color");
      }
      
      private function __menuTransAnimation(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Animation");
      }
      
      private function __menuTransPivot(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Pivot");
      }
      
      private function __menuTransSound(param1:Event) : void
      {
         this._editPanel.timelinePanel.createTimeline("","Sound");
      }
      
      private function __menuTransTrans(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Transition");
      }
      
      private function __menuTransShake(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Shake");
      }
      
      private function __menuTransController(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Controller");
      }
      
      private function __menuTransVisible(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"Visible");
      }
      
      private function __menuTransColorFilter(param1:Event) : void
      {
         var _loc2_:String = this._selections.length > 0?this._selections[0].id:"";
         this._editPanel.timelinePanel.createTimeline(_loc2_,"ColorFilter");
      }
   }
}
